/**
    @author: dt
    @date: 2025-06-23
    @description: 装饰器节点基类
*/

using UnityEngine;

namespace DLib.BehaviorTree
{
    /// <summary>
    /// 装饰器节点基类
    /// 用于修饰单个子节点的行为
    /// 装饰器只能有一个子节点，可以修改子节点的执行结果
    /// </summary>
    public abstract class DecoratorNode : Node
    {
        /// <summary>装饰器的子节点</summary>
        protected Node child;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="child">要装饰的子节点</param>
        public DecoratorNode(Node child)
        {
            this.child = child;
            child.parent = this;
        }

        /// <summary>
        /// 评估装饰器节点
        /// 调用子类实现的EvaluateChild方法来处理子节点结果
        /// </summary>
        /// <returns>装饰器执行状态</returns>
        public override NodeState Evaluate()
        {
            return EvaluateChild();
        }

        /// <summary>
        /// 评估子节点的抽象方法
        /// 子类必须实现此方法来定义具体的装饰逻辑
        /// </summary>
        /// <returns>装饰器执行状态</returns>
        protected abstract NodeState EvaluateChild();
    }
} 